{extend name="public:layout" /}
{block name="title"}选择司机{/block}
{block name="head"}

{/block}
{block name="body"}
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <ol class="breadcrumb">
                    <li class="active"><i class="fa fa-hand-o-right"></i> 司机列表</li>
                </ol>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <div class="pull-left">
                    <form class="form-inline" id="searchForm" method="post">
                        <div class="form-group">
                            <input class="form-control" type="text" placeholder="司机姓名" name="title" value="{$query.title}" style="width:80px" />
                        </div>
                        <div class="form-group">
                            <input class="form-control" type="text" name="btime" value="{$query.btime}" readonly />
                        </div>
                        <div class="form-group">
                            <input class="form-control" type="text" name="etime" value="{$query.etime}" readonly />
                        </div>
                        <div class="form-group">
                            <input class="form-control" type="text" placeholder="日期间隔" name="date_day" value="{$query.date_day}" style="width:60px" />
                        </div>
                        <button type="submit" class="btn btn-info"><i class="fa fa-search"></i> 搜索</button>
                        <a class="btn btn-white" href="{:url('index',['mid'=>$Request.param.mid])}">
                            <i class="fa fa-trash"></i> 清空
                        </a>
                    </form>
                </div>
                <div class="pull-right">
                    已选择<span id="car_num" class="text-danger">0</span>司机
                </div>
                <div class="clearfix"></div>
            </div>
            <table class="table table-bordered" id="grid">
                <tr>
                    <th>#</th>
                    <th>司机姓名</th>
                    <th>司机电话</th>
                    <th>驾驶证号</th>
                    <th>当前状态</th>
                </tr>
                {volist name="list" id="vo"}
                <tr>
                    <td>
                        <input name="aid[]" type="checkbox" class="checkbox" data-name="{$vo.title}" value="{$vo.aid}" />
                    </td>
                    <td>{$vo.title}</td>
                    <td>{$vo.dri_phone}</td>
                    <td>{$vo.dri_license}</td>
                    <td>{$vo.dri_status_text}</td>
                </tr>
                {/volist}
            </table>
            <input id="drivers" type="hidden" value="" />
            <input id="driver_ids" type="hidden" value="" />
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    $(function () {
        $('.checkbox').change(function () {
            var drivers = '';
            var reVal = '';
            var car_num=0;
            $("#grid :checkbox").each(function () {
                if ($(this).prop("checked")) {
                    drivers += $(this).data('name')+",";
                    reVal += $(this).val() + ",";
                    car_num+=1;
                }
            });
            drivers = drivers.substr(0, drivers.length - 1);
            reVal = reVal.substr(0, reVal.length - 1);
            $('#drivers').val(drivers);
            $('#driver_ids').val(reVal);
            $('#car_num').text(car_num);
        });
    })
</script>
{/block}